package com.net.xpay.common.manager.impl.admin.rbac;

import com.google.common.base.Preconditions;
import com.net.common.annotation.ReadTransactional;
import com.net.common.dao.BasicMapper;
import com.net.common.manager.AbstractManager;
import com.net.xpay.common.dao.admin.rbac.AdminUserRoleMapper;
import com.net.xpay.common.domain.admin.rbac.AdminUserRole;
import com.net.xpay.common.manager.admin.rbac.AdminUserRoleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
@ReadTransactional
public class AdminUserRoleManagerImpl extends AbstractManager<AdminUserRole> implements AdminUserRoleManager{

    @Autowired
    private AdminUserRoleMapper mapper;


    @Override
    protected BasicMapper<Long, AdminUserRole> getMapper() {
        return mapper;
    }

    @Override
    public List<AdminUserRole> listByAdminUserId(Long adminUserId) {
        Preconditions.checkArgument(adminUserId != null);
        AdminUserRole condition = new AdminUserRole();
        condition.setAdminUserId(adminUserId);
        return listByCondition(condition, new ArrayList<>());
    }

    @Override
    public int deleteByAdminUserId(Long adminUserId) {
        Preconditions.checkArgument(adminUserId != null);
        AdminUserRole condition = new AdminUserRole();
        condition.setAdminUserId(adminUserId);
        return deleteByCondition(condition);
    }
}
